package jgl.vajra.operator.part.order.viewModel;

import java.util.List;
import java.util.Map;

import jgl.vajra.operator.bean.MachineGuyBean;
import jgl.vajra.operator.part.order.contract.ReplaceDriverContract;
import jgl.vajra.operator.part.order.model.ReplaceDriverModel;
import jgl.vajra.operator.widget.mvvm.factory.CreateModel;
import jgl.vajra.operator.widget.retrofithelper.rxsubscriber.ProgressObserver;

@CreateModel(ReplaceDriverModel.class)
public class ReplaceDriverViewModel extends ReplaceDriverContract.ViewModel{
    @Override
    public void getMachineGuyData(Map<String, Object> map) {
        mModel.getMachineGuyData(map).subscribe(new ProgressObserver<List<MachineGuyBean>>(true, this) {
            @Override
            public void _onNext(List<MachineGuyBean> data) {
                mView.returnMachineGuyData(data);
            }

            @Override
            public void _onError(String errorMessage, int errorCode) {
                super._onError(errorMessage, errorCode);
            }
        });
    }

    @Override
    public void replaceDriver(Map<String, Object> map) {
        mModel.replaceDriver(map).subscribe(new ProgressObserver<String>(true, this) {
            @Override
            public void _onNext(String data) {
                mView.returnReplaceDriver(data);
            }

            @Override
            public void _onError(String errorMessage, int errorCode) {
                super._onError(errorMessage, errorCode);
            }
        });
    }
}
